"""

Computational Economics
2.1: Functions
http://johnstachurski.net/lectures/functions.html

    The Fibonacci numbers are defined by:

        x_t+1 = x_t + x_t-1, x_0 = 0, x_1 = 1

    The first few numbers in the sequence are: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34

    Write a function to recursively compute the t-th Fibonacci number for any t


"""

def fibonacci(n):
    if n in (0, 1):
        return n
    else:
        return fibonacci(n-1) + fibonacci(n-2)

test_cases = [0, 1, 1, 2, 3, 5, 8, 13, 21, 34]

for i in range(len(test_cases)):
    assert fibonacci(i) == test_cases[i]

print fibonacci(20)



print '%s: ok' % (__file__)

